using System;
using System.Collections.Generic;
using System.Text;
using ZombieHigh2.Parser;
using System.Xml;

namespace ZombieHigh2.World
{
    public class WorldData
    {
        DeledParser parser;
        String levelName;

        public delegate void LoadingComplete();
        public event LoadingComplete OnLoadComplete;

        public DeledParser Parser
        {
            get { return parser; }
        }

        public WorldData(DeledParser parser)
        {
            this.parser = parser;
        }

        public void SetLevelToLoad(String levelName)
        {
            this.levelName = levelName;
        }

        public void Load()
        {
            //Load the XML document describing the world
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.Load(@"Data\Levels\" + levelName);

            parser.ParseMapData(xmldoc);
            //parser.ReadMaterials(xmldoc);
            //parser.ReadPrimitives(xmldoc);
            //parser.ParseCustomContent();

            //for (int i = 0; i < 100000; i++)
            //{
            //    for (int j = 0; j < 10000; j++)
            //    {
            //        int k = 0;
            //    }
            //}

            OnLoadingComplete();
        }

        void OnLoadingComplete()
        {
            if (OnLoadComplete != null)
            {
                OnLoadComplete();
            }
        }
    }
}
